<?php

class Connection {

    private $connectionId;

    function __construct () {
        try {
            $this->connectionId = mysql_connect("localhost","fravico", "ad18sVA5sMSU");
            if(!$this->connectionId) {
                throw new Exception("Unable to establish connection with the database server.");
            }
            if(!mysql_select_db("fravico_fravidb", $this->connectionId)) {
                throw new Exception("Unable to select the specified database.");
            }
        } catch(Exception $e) {
            throw new Exception();
        }
    }

    function __destruct () {
        //mysql_close($this->connectionId);
    }

    function execute ($query) {
        $result = mysql_query($query, $this->connectionId);
        if(!$result) {
            throw new Exception("Query execution failed :: " .$query);
        }
        return $result;
    }

    function disconnect () {
        mysql_close($this->connectionId);
    }
}
?>
